package model;

/**
 * ServiceCall.java
 * Purpose: Represents a service call in the system
 * 
 * @author Hans Brems
 * @version 1.0 31/05/2012
 */

import java.io.Serializable;
import javax.persistence.*;
import java.util.Date;
import java.util.Set;

@SuppressWarnings("serial")
@Entity
public class ServiceCall implements Serializable {
	/* Reference */
	@Id
	@Column(name="servicecall_id")
	private int id;
	/* Is the service call active in the database */
	private boolean active;
	/* Description */
	private String description;
	/* Priority */
	@Column(name="priority_code")
	private String priorityCode;
	/* Start time */
    @Temporal( TemporalType.TIMESTAMP)
	@Column(name="start_time")
	private Date startTime;
    /* Stop time */
    @Temporal( TemporalType.TIMESTAMP)
	@Column(name="stop_time")
	private Date stopTime;
    /* Status code */
	@Column(name="status_code")
	private String statusCode;

	// Bi-directional many-to-one association to product
    @ManyToOne
	@JoinColumn(name="product_id")
	private Product product;
  
	// Bi-directional many-to-one association to Operator
    @ManyToOne
	@JoinColumn(name="operator_id")
	private Operator operator;

	// Bi-directional many-to-one association to Task
	@OneToMany(mappedBy="servicecall")
	private Set<Task> tasks;
	
	@ManyToOne
	@JoinColumn(name="customer_id")
	private Customer customer;

	/** Constructs a new service call */
    public ServiceCall() {
    }

    /** Returns the id of the service call */
	public int getId() {
		return this.id;
	}

	/** Sets the id of the service call */
	public void setId(int id) {
		this.id = id;
	}

	/** Returns the active state of the service call */
	public boolean isActive() {
		return this.active;
	}

	/** Sets the active state of the service call */
	public void isActive(boolean active) {
		this.active = active;
	}

	/** Returns the description of the service call */
	public String getDescription() {
		return this.description;
	}

	/** Sets the description of the service call */
	public void setDescription(String description) {
		this.description = description;
	}

	/** Returns the priority code of the service call */
	public String getPriorityCode() {
		return this.priorityCode;
	}

	/** Sets the priority code of the service call */
	public void setPriorityCode(String priorityCode) {
		this.priorityCode = priorityCode;
	}

	/** Returns the start time of the service call */
	public Date getStartTime() {
		return this.startTime;
	}

	/** Sets the start time of the service call */
	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	/** Sets the stop time of the service call */
	public void setStopTime(Date stopTime) {
		this.stopTime = stopTime;
	}
	
	/** Returns the status code of the service call */
	public String getStatusCode() {
		return this.statusCode;
	}

	/** Sets the status code of the service call */
	public void setStatusCode(String statusCode) {
		this.statusCode = statusCode;
	}

	/** Returns the stop time of the service call */
	public Date getStopTime() {
		return this.stopTime;
	}

	/** Returns the product */
	public Product getProduct() {
		return this.product;
	}

	/** Sets the product */
	public void setProduct(Product product) {
		this.product = product;
	}
	
	
	/** Returns the customer */ 
	public Customer getCustomer() {
		return this.customer;
	}

	/** Sets the product */ 
	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
	
	/** Returns the operator */
	public Operator getOperator() {
		return this.operator;
	}

	/** Sets the operator */
	public void setOperator(Operator operator) {
		this.operator = operator;
	}
	
	/** Returns the tasks associated with the service call */
	public Set<Task> getTasks() {
		return this.tasks;
	}

	/** Sets the tasks associated with the service call */
	public void setTasks(Set<Task> tasks) {
		this.tasks = tasks;
	}
	
	public String toString(){
		return ""+this.getId();
	}
}
